<template>
  <div style="height:100%;width:100%;position:relative;">
      <div class="pagetop">
          <div style="width:100%;">
              <div style="float:left;width:70%">
                  <table border="0">
                      <tr>
                          <td>报告单元</td>
                          <td>
                              <rm-ddl-rptunit prgno="LIS341" :clearable="false" defaultflag="1" v-model="rptunit" width="160px"></rm-ddl-rptunit>
                          </td>
                          <td>报告日期</td>
                          <td>
                              <el-date-picker v-model="datetime1" type="date" align="right" value-format="yyyy-MM-dd 00:00:00" size="mini" placeholder="开始日期" :clearable="false" style="width:130px"></el-date-picker> 至
                              <el-date-picker v-model="datetime2" type="date" align="right" value-format="yyyy-MM-dd 23:59:59" size="mini" placeholder="结束日期" :clearable="false" style="width:130px"></el-date-picker>
                          </td>
                          <td>
                              <el-radio-group v-model="sendflag">
                                  <table>
                                      <tr>
                                          <td>
                                              <el-radio label="99">全部</el-radio>
                                          </td>
                                          <td>
                                              <el-radio label="1">已发送</el-radio>
                                          </td>
                                          <td>
                                              <el-radio label="0">未发送</el-radio>
                                          </td>
                                          <td>
                                              <el-radio label="2">发送失败</el-radio>
                                          </td>
                                      </tr>
                                  </table>
                              </el-radio-group>
                          </td>
                      </tr>
                      <tr>
                          <td>标本号</td>
                          <td>
                              <el-input v-model="sampleno" style="width:160px" placeholder="1,2,5-8等格式,为空表示全部"></el-input>
                          </td>
                          <td>条码号</td>
                          <td>
                              <el-input v-model="barcode"></el-input>
                          </td>

                      </tr>
                  </table>
              </div>
              <div style="float:left;width:30%">
                  <div style="position:absolute;top:50px;right:5px">
                      <el-button @click="QueryTask()" type="primary">查询</el-button>
                      <el-button @click="ReSend()">重新发送</el-button>
                  </div>
              </div>
          </div>
      </div>
      <div class="pagecenter">
          <vxe-table :data="tableData" :loading="loading" border fit height="auto" header-align="center" highlight-current-row highlight-hover-row ref="tabledual" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe>
              <vxe-table-column type="selection" width="50px" align="center"></vxe-table-column>
              <vxe-table-column field="rptunitid" title="报告单元" width="160px" align="center"></vxe-table-column>
              <vxe-table-column field="sampledate" title="标本日期" width="100px" align="center"></vxe-table-column>
              <vxe-table-column field="sampleno" title="标本编号" width="60px"></vxe-table-column>
              <vxe-table-column field="barcode" title="条码号" width="120px" align="center"></vxe-table-column>
              <vxe-table-column field="createdt" title="生成时间" width="180px" align="center"></vxe-table-column>
              <vxe-table-column field="sendflagname" title="发送标志" width="60px" align="center"></vxe-table-column>
              <vxe-table-column field="senddt" title="发送时间" width="120px" align="center"></vxe-table-column>
              <vxe-table-column field="sendfailcnt" title="失败次数" width="60px" align="right" header-align="center"></vxe-table-column>
              <vxe-table-column field="sendmsg" title="发送信息" width="160px"></vxe-table-column>
              <vxe-table-column field="rachno" title="架号" width="60px"></vxe-table-column>
              <vxe-table-column field="posno" title="位置号" width="60px"></vxe-table-column>
              <vxe-table-column field="rptitemids" title="双工报告项目" width="160px"></vxe-table-column>
              <vxe-table-column field="reportid" title="报告ID" width="100px" align="center"></vxe-table-column>
          </vxe-table>
      </div>
  </div>
</template>


<script>
import { Promise } from "q";
import { invalid } from "moment";
export default {
  name: "LIS341",
  data() {
      return {
          rptunit: 0,
          datetime1: "",
          datetime2: "",
          sampleno: "",
          barcode: "",
          sendflag: "2",
          tableData: [],
          loading: false,
      };
  },
  created() {
      this.InitPageData();
  },
  mounted() {},
  updated() {},
  methods: {
      InitPageData() {
          this.$tool
              .request({
                  url: "/LIS/LIS3/LIS341",
                  method: "post",
                  data: {
                      action: "InitPage",
                  },
              })
              .then((res) => {
                  this.datetime1 = res.time + " 00:00:00";
                  this.datetime2 = res.time + " 23:59:59";
              })
              .catch((err) => {});
      },
      QueryTask() {
          this.loading = true;
          this.$tool
              .request({
                  url: "/LIS/LIS3/LIS341",
                  method: "post",
                  data: {
                      action: "querytask",
                      datetime1: this.datetime1,
                      datetime2: this.datetime2,
                      barcode: this.barcode,
                      sampleno: this.sampleno,
                      rptunitid: this.rptunit,
                      sendflag: this.sendflag,
                  },
              })
              .then((res) => {
                  this.tableData = res.RData.Data;
                  this.loading = false;
              })
              .catch((err) => {
                  this.loading = false;
              });
      },
      ReSend() {
          var data = this.$refs.tabledual.getSelectRecords();
          if (data.length > 0) {
              let reportids = "";
              data.forEach((item) => {
                  reportids += item.reportid + ",";
              });
              reportids = reportids.substring(0, reportids.length - 1);
              let msg = "";
              if (data.length == 1) {
                  msg = "您确定要重新发送报告ID为" + reportids + "的双工申请吗?";
              } else {
                  msg = "您确定要重新发送双工申请吗，共" + data.length + "份报告?";
              }
              this.$confirm(msg, "提示", {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  focusCancelButton: true,
                  closeOnClickModal: false,
                  type: "warning",
              }).then(() => {
                  this.$tool
                      .request({
                          url: "/LIS/LIS3/LIS341",
                          method: "post",
                          data: {
                              action: "resend",
                              reportids: reportids,
                          },
                      })
                      .then((res) => {
                          if (res.flag == "1") {
                              this.$message({
                                  message: res.msg,
                                  type: "success",
                              });
                              this.QueryTask();
                          } else {
                              if (res.hasOwnProperty("msg")) {
                                  this.$message.error("重新发送错误:" + res.msg);
                              } else {
                                  this.$message.error("重新发送错误:" + res.errmsg);
                              }
                          }
                      })
                      .catch((err) => {
                          this.$message.error("重新发送错误:" + err);
                      });
              });
          } else {
              this.$confirm("请选择要重新发送的数据!", "提示", {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  focusCancelButton: false,
                  closeOnClickModal: false,
                  type: "warning",
              });
          }
      },
  },
};
</script>

<style scoped>
/deep/.el-input.is-disabled .el-input__inner {
  color: black;
}
/deep/.el-checkbox.is-disabled .el-checkbox__label {
  color: black;
}
/deep/.el-textarea.is-disabled .el-textarea__inner {
  color: black;
}
/deep/.vxe-button--wrapper {
  width: 100%;
}
.pagetop {
  left: 0;
  right: 0;
  height: 80px;
  display: -webkit-box;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  border: solid 1px #ccc;
  position: absolute;
  z-index: 99;
}

.pagecenter {
  position: absolute;
  top: 85px;
  width: 100%;
  left: 0;
  bottom: 0px;
}

.middle-center {
  position: absolute;
  height: 100%;
  left: 505px;
  right: 0;
}

.middle-left {
  position: absolute;
  height: 100%;
  width: 500px;
  left: 0px;
  top: 0;
}

table tr td:nth-child(odd) {
  text-align: right;
  line-height: 32px;
  white-space: nowrap;
}
table tr td:nth-child(even) {
  text-align: left;
}
table {
  font-size: 12px;
}
td {
  padding: 0 5px 0 0;
}
/deep/.el-checkbox__inner::after {
  border: 2px solid #000000 !important;
  box-sizing: content-box;
  content: "";
  border-left: 0 !important;
  border-top: 0 !important;
  height: 7px;
  left: 4px;
  position: absolute;
  top: 1px;
  transform: rotate(45deg) scaleY(0);
  width: 3px;
  transition: transform 0.15s ease-in 0.05s;
  transform-origin: center;
}
/deep/.el-checkbox__input.is-disabled + span.el-checkbox__label {
  color: #000000;
  cursor: not-allowed;
}
/deep/ .el-checkbox__input.is-disabled .el-checkbox__inner,
.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner + .el-input.is-disabled .el-input__inner {
  background-color: #ffffff !important;
}
</style>